<?php
/*
通用分类
*/
class Con_domain extends Acan{
	public $defaultAct='list';
	function __construct($ainfo=null){
		parent::__construct($ainfo=null);
		if(empty($this->id) || $this->id == '*'){
			$this->id = '0';
		}
		$this->model = Afun_db()->model(Atable_dz_common_domain);
	}
	function Act_list(){
		//分页函数
	//	$con->where = "`pid`='$this->id'";
		$page->theurl = $this->Aactr.'-'.$this->id;
		$page->by = 'idtype';
		$page->page = '20';
		$page->counts = $this->model->count($con);	//统计总数目
		$pages = Afun_apage($page);
		$con->order = "a.$pages->orderby,a.id asc";
		$con->limit = $pages->limit;
		//分页结束
		$lists = $this->model->findAll($con);
		include $this->Atpl();
	}
	//批量更新
	function Act_save(){
		Afun_post_auth();
		foreach($_POST['save'] as $i=>$vals){
			$this->model->update($vals,"id='".$vals['o_id']."' and idtype='".$vals['o_idtype']."'");
		}
		Afun_refresh('保存成功','referrer');
	}
	//添加
	function Act_add(){
		Afun_post_auth();
		if($msg = $this->model->save($_POST['add'])){
			Afun_refresh('添加成功','referrer');
		}else{Afun_refresh('添加失败'.$msg,'referrer');}
	}
	//删除
	function Act_del(){
		Afun_post_auth();
		$c = explode(',',$this->id);
		if($this->model->delete("id='".$c[0]."' and idtype='".$c[1]."'")){
			Afun_refresh('删除成功','referrer');
		}
	}
	//删除所选
	function Act_delall(){
		Afun_post_auth();
		foreach($_POST['chk'] as $key=>$val){
			if(empty($vala))
				$vala = "'$val'";
			else
				$vala .=",'$val'";
		}
		$this->model->delete($this->model->key_name." IN ($vala)");
		Afun_refresh("删除成功",'referrer');
	}
	function Act_updatecache(){
		Afun_post_auth();
		require A_ROOT.'/../source/function/function_cache.php';
		unlink(A_ROOT.'/../data/cache/cache_domain.php');
		updatecache();//有数据库操作更新缓存
		Afun_refresh("更新成功",'referrer');
	}
	
}

?>